package com.anolesoft.amljmes.screen.controller;

import com.anolesoft.amljmes.screen.dto.MesOrderTimeoutLogs;
import com.anolesoft.amljmes.screen.mapper.MesOrderAssessMapper;
import com.anolesoft.amljmes.screen.service.MesOrderTimeoutLogsService;
import com.anolesoft.amljmes.screen.vo.MesOrderViewVo;
import com.anolesoft.common.core.constant.HttpStatus;
import com.anolesoft.common.core.web.domain.AjaxResult;
import com.anolesoft.yr.util.Constants;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/messcreenkh")
public class MesOrderAssessController {

    @Autowired
    private MesOrderTimeoutLogsService mesOrderTimeoutLogsService;
    @Resource
    private MesOrderAssessMapper mesOrderAssessMapper;

    @RequestMapping(value = "/querykaohedata" , method = RequestMethod.POST)
    public AjaxResult queryScreen(@RequestBody MesOrderTimeoutLogs mesOrderTimeoutLogs){
        List<MesOrderViewVo> list = new ArrayList<>();
        String nianyue = mesOrderTimeoutLogs.getNianyue();
        if (nianyue != null && nianyue != "") {
            // 如果存在年月查询一张表
            System.out.println("存在年月");
        } else {
            // 没有年月
            String jx = mesOrderTimeoutLogs.getJx().toUpperCase();
            list =  mesOrderTimeoutLogsService.querytongji(jx);
            // 根据厂代号添加考核项
            for (MesOrderViewVo item:list) {
                MesOrderTimeoutLogs mesOrderTimeoutLogs1 = new MesOrderTimeoutLogs();
                mesOrderTimeoutLogs1.setFactoryId(item.getFactoryId());
                if (jx != null) {
                    mesOrderTimeoutLogs1.setJx(jx);
                }
                int kaohe = mesOrderAssessMapper.selectone(mesOrderTimeoutLogs1);
                item.setKaohexiang(kaohe + "");
            }
        }
        return new AjaxResult(HttpStatus.SUCCESS, Constants.QUERY_SUCCESS_MESSAGE,list);
    }
}
